package com.wy.example;

import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;

import java.io.*;

//将已经实现的方式写在这个里面，等整个架子完善之后再写进去，
public class demo {
    // 还需要进一步的封装 传入流呀，返回不同的东西呀。什么的。
    public void excelToPic(String sourceFileName,String targetFileName) throws IOException {
        FileInputStream fileInputStream = new FileInputStream(sourceFileName);
        //加载Excel工作表
        Workbook wb = new Workbook();
        wb.loadFromStream(fileInputStream);
        Worksheet sheet = wb.getWorksheets().get(0);
        sheet.saveToImage(targetFileName);
//        try {
//            FileInputStream fis = new FileInputStream(new File(path));
//            ByteArrayOutputStream bos = new ByteArrayOutputStream();
//            byte[] buffer = new byte[1024];
//            int bytesRead;
//            while ((bytesRead = fis.read(buffer)) != -1) {
//                bos.write(buffer, 0, bytesRead);
//            }
//            picByte = bos.toByteArray();
//            fis.close();
//            bos.close();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        //将 byte 数组输出到 本地
//        FileOutputStream fileOutputStream = new FileOutputStream(targetFileName);
//        fileOutputStream.write(picByte);


    }

    public static void main(String[] args) throws IOException {
        demo demo = new demo();
        demo.excelToPic("C:\\Users\\Administrator\\Downloads\\2024.10.14-10.18周货源投放策略(太原).xls","C:\\Users\\Administrator\\Downloads\\1.jpg");
    }
}
